package gov.child.dao;

import gov.child.dao.exception.EntityDeleteException;
import gov.child.dao.exception.EntityQueryException;
import gov.child.dao.exception.EntitySaveException;
import gov.child.dao.exception.EntityUpdateException;
import gov.child.entities.po.ECollection;
import gov.child.entities.po.EUser;

import java.util.List;

/**
 * The interface Collection dao. --finish
 *
 * @author fzh
 * @since 2017 /9/9
 */
public interface CollectionDao {
    /**
     * 根据ID查询
     *
     * @param id the id
     * @return the by id
     */
    ECollection findById(Integer id) throws EntityQueryException;

    /**
     * 根据用户查询
     *
     * @param user the user
     * @return the by user
     */
    default List findByUser(EUser user) throws EntityQueryException {
        return findByUserId(user.getId());
    }

    List findByUserId(Integer userId) throws EntityQueryException;

    /**
     * 删除
     *
     * @param collection the collection
     */
    void delete(ECollection collection) throws EntityDeleteException;

    /**
     * 保存
     *
     * @param collection the collection
     */
    void save(ECollection collection) throws EntitySaveException;

    /**
     * 更新
     *
     * @param collection the collection
     */
    void update(ECollection collection) throws EntityUpdateException;
}
